<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Spout</title>
</h:head>
<h:body>
	<h:outputLink value="cluster.jsf">
		<h1>
			<h:outputText value="JStorm Cluster" />
			<f:param name="clusterName" value="#{param.clusterName}" />
		</h1>
	</h:outputLink>
	<h2>Summary</h2>
	<h:form>
		<p:dataTable id="componenttable" var="com" value="#{spoutpage.coms}">
			<p:column>
				<f:facet name="header">
					<h:outputText value="Component Id" />
				</f:facet>
				<h:outputText value="#{com.componentId}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Topology Name" />
				</f:facet>
				<h:outputLink value="topology.jsf">
					<h:outputText value="#{com.topologyname}" />
					<f:param name="clusterName" value="#{param.clusterName}" />
					<f:param name="topologyid" value="#{param.topologyid}" />
				</h:outputLink>
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Parallelism" />
				</f:facet>
				<h:outputText value="#{com.parallelism}" />
			</p:column>

		</p:dataTable>
	</h:form>
	<h2>
		<h:outputText value="Component stats" />
		<span style="display: inline-block;">
			<form name="aaa" action="spout.jsf" method="post">
                                <input id="clusterName" name="clusterName" type="hidden"
					value="#{param.clusterName}" />
				<input id="topologyid" name="topologyid" type="hidden"
					value="#{param.topologyid}" /> 
				<input id="componentid" name="componentid" type="hidden" 
					value="#{param.componentid}" /> 
				<input id="windowpara" name="windowparaname" type="hidden"
					value="#{param.window}" /> 
				<select id="window" name="window" onchange="submit();">
					<option value="0d0h10m0s">0d0h10m0s</option>
					<option value="0d3h0m0s">0d3h0m0s</option>
					<option value="1d0h0m0s">1d0h0m0s</option>
					<option value="All-time">All-time</option>
				</select>
			</form>
		</span>

	</h2>

	<h:form>
		<p:dataTable id="statstable" var="stats" value="#{spoutpage.comstats}"
			sortBy="#{stats.window}" sortOrder="ASCENDING">

			<p:column>
				<f:facet name="header">
					<h:outputText value="Window" />
				</f:facet>
				<h:outputText value="#{stats.window}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Emitted" />
				</f:facet>
				<h:outputText value="#{stats.emitted}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Send TPS" />
				</f:facet>
				<h:outputText value="#{stats.sendTps}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Recv TPS" />
				</f:facet>
				<h:outputText value="#{stats.recvTps}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Process latency (ms)" />
				</f:facet>
				<h:outputText value="#{stats.process}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Acked" />
				</f:facet>
				<h:outputText value="#{stats.acked}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Failed" />
				</f:facet>
				<h:outputText value="#{stats.failed}" />
			</p:column>
		</p:dataTable>
	</h:form>

	<h2>
		<h:outputText value="Output stats(#{pm.window})" />
	</h2>
	<h:form>
		<p:dataTable id="outputstable" var="coo" value="#{spoutpage.coos}"
			sortBy="#{coo.stream}" sortOrder="ASCENDING">

			<p:column>
				<f:facet name="header">
					<h:outputText value="Stream" />
				</f:facet>
				<h:outputText value="#{coo.stream}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Emitted" />
				</f:facet>
				<h:outputText value="#{coo.emitted}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Send TPS" />
				</f:facet>
				<h:outputText value="#{coo.sendTps}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Process latency (ms)" />
				</f:facet>
				<h:outputText value="#{coo.process}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Acked" />
				</f:facet>
				<h:outputText value="#{coo.acked}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Failed" />
				</f:facet>
				<h:outputText value="#{coo.failed}" />
			</p:column>
		</p:dataTable>
	</h:form>

	<h2>
		<h:outputText value="Tasks(#{pm.window})" />
	</h2>
	<h:form>
		<p:dataTable id="taskstable" var="ct" value="#{spoutpage.cts}"
			sortBy="#{ct.taskid}" sortOrder="ASCENDING">

			<p:column>
				<f:facet name="header">
					<h:outputText value="Taskid" />
				</f:facet>
				<h:outputText value="#{ct.taskid}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Status" />
				</f:facet>
				<h:outputText value="#{ct.status}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Uptime" />
				</f:facet>
				<h:outputText value="#{ct.uptime}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Host" />
				</f:facet>
				<!--<h:outputText value="#{ct.host}" />-->
				<h:outputLink value="supervisor.jsf">
				<h:outputText value="#{ct.host}" />
				    <f:param name="clusterName" value="#{param.clusterName}" />
					<f:param name="host" value="#{ct.host}" />
				</h:outputLink>
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Port" />
				</f:facet>
				<h:outputText value="#{ct.port}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Emitted" />
				</f:facet>
				<h:outputText value="#{ct.emitted}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Send TPS" />
				</f:facet>
				<h:outputText value="#{ct.sendTps}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Recv TPS" />
				</f:facet>
				<h:outputText value="#{ct.recvTps}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Process latency (ms)" />
				</f:facet>
				<h:outputText value="#{ct.process}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Acked" />
				</f:facet>
				<h:outputText value="#{ct.acked}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Failed" />
				</f:facet>
				<h:outputText value="#{ct.failed}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Task Log" />
				</f:facet>
				<h:outputLink value="log.jsf" target="_blank">
					<h:outputText value="log" />
					<f:param name="clusterName" value="#{param.clusterName}" />
					<f:param name="topologyid" value="#{param.topologyid}" />
					<f:param name="taskid" value="#{ct.taskid}" />
				</h:outputLink>
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Last Error" />
				</f:facet>
				<h:outputText value="#{ct.lastErr}" />
			</p:column>


		</p:dataTable>
	</h:form>
	<h2>
		<h:outputText value="Task Metrics(Time AND Queue)" />
	</h2>
	<h:form>
		<p:dataTable id="taskmetrics" var="tm" value="#{spoutpage.taskmetrics}"
			sortBy="#{tm.taskId}" sortOrder="ASCENDING">
			<p:column>
				<f:facet name="header">
					<h:outputText value="Taskid" />
				</f:facet>
				<h:outputText value="#{tm.taskId}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Deserialize: Time(ms)" />
				</f:facet>
                                <h:outputText value="#{tm.deserializeTime}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Deserialize: Queue(%)" />
				</f:facet>
				<h:outputText value="#{tm.deserializeQueue}" />
			</p:column>

                        <p:column>
				<f:facet name="header">
					<h:outputText value="NextTuple: Time(ms)" />
				</f:facet>
				<h:outputText value="#{tm.executorTime}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Execute: Queue(%)" />
				</f:facet>
				<h:outputText value="#{tm.executorQueue}" />
			</p:column>

                        <p:column>
			    <f:facet name="header">
				<h:outputText value="Serialize: Time(ms)" />
			    </f:facet>
			    <h:outputText value="#{tm.serializeTime}" />
                        </p:column>

			<p:column>
			    <f:facet name="header">
				<h:outputText value="Serialize: Queue(%)" />
			    </f:facet>
			    <h:outputText value="#{tm.serializeQueue}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Pending Num" />
				</f:facet>
				<h:outputText value="#{tm.pendingNum}" />
			</p:column>

                        <p:column>
				<f:facet name="header">
					<h:outputText value="Emit Time(ms)" />
				</f:facet>
				<h:outputText value="#{tm.emitTime}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Acker Time(ms)" />
				</f:facet>
				<h:outputText value="#{tm.ackerTime}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Empty CPU Ratio" />
				</f:facet>
				<h:outputText value="#{tm.emptyCpuRatio}" />
			</p:column>

		</p:dataTable>
	</h:form>
</h:body>
<script>
   var windowpara=document.getElementById("windowpara");
   var windowselect=document.getElementById("window");
   
   if(windowselect.options[0].text == windowpara.value){
       windowselect.options[0].selected=true;
       return;
   }
   
   if(windowselect.options[1].text == windowpara.value){
       windowselect.options[1].selected=true;
       return;
   }
   
   if(windowselect.options[2].text == windowpara.value){
       windowselect.options[2].selected=true;
       return;
   }
   
   if(windowselect.options[3].text == windowpara.value){
       windowselect.options[3].selected=true;
       return;
   }

</script>
</html>


